#ifdef _WIN32 
#include <windows.h> 
#endif

#include "GUI.h"

namespace Gadgets
{

GUI::GUI() :
		LuaScript()
{
	screen = new Form(Engine::screenSettings.screenWidth,
			Engine::screenSettings.screenHeight);
}

GUI::~GUI(void)
{
	_clean();
	delete (screen);
}

void GUI::bindClass()
{
	// push form datatype to lua
	luabind::module(LuaState)[luabind::class_ < Form
			> ("Form").def(luabind::constructor<int, int>()).def("setBackground",
					&Form::setBackground).def("getCountOfItems", &Form::getCountOfItems).def(
					"addItem", &Form::addItem).def("getHeight", &Form::getHeight).def(
					"setHeight", &Form::setHeight).def("getWidth", &Form::getWidth).def(
					"setWidth", &Form::setWidth).def("setVisible", &Form::setVisible).def(
					"isVisible", &Form::isVisible).def("setPos",
					(void (Form::*)(int, int))&Form::setPos).def("getPosX", &Form::getPosX)
					.def("getPosY", &Form::getPosY),

					luabind::class_<Label, Form>("Label")
					.def(luabind::constructor<int, int>())
					.def("setBackground", &Label::setBackground)
					.def("getCountOfItems", &Label::getCountOfItems)
					.def("addItem", &Label::addItem)
					.def("getHeight", &Label::getHeight)
					.def("setHeight", &Label::setHeight)
					.def("getWidth", &Label::getWidth)
					.def("setWidth", &Label::setWidth)
					.def("setVisible", &Label::setVisible)
					.def("isVisible", &Label::isVisible)
					.def("setPos", (void (Label::*)(int, int))&Label::setPos)
					.def("getPosX", &Label::getPosX)
					.def("getPosY", &Label::getPosY)
					.def("setCaption", &Label::setCaption),

					luabind::class_<Button, Form>("Button")
					.def(luabind::constructor<int, int>())
					.def("setBackground", &Button::setBackground)
					.def("getCountOfItems", &Button::getCountOfItems)
					.def("addItem", &Button::addItem)
					.def("getHeight", &Button::getHeight)
					.def("setHeight", &Button::setHeight)
					.def("getWidth", &Button::getWidth)
					.def("setWidth", &Button::setWidth)
					.def("setVisible", &Button::setVisible)
					.def("isVisible", &Button::isVisible)
					.def("setPos", (void (Button::*)(int, int))&Button::setPos)
					.def("getPosX", &Button::getPosX)
					.def("getPosY", &Button::getPosY)
					];

					// push this object reference to lua script
					table[ "screen" ] = screen;
				}

void GUI::draw()
{
	screen->draw();
}

GUI *gameGui = NULL;

void initGui()
{
	gameGui = new GUI();
}

void deleteGui()
{
	delete (gameGui);
}
}